package com.allwees.support.fileservice.model;

import com.aliyun.oss.model.ObjectMetadata;
import com.allwees.core.common.util.reflect.ReflectionUtils;

/**
 * 文件元数据信息(含用户自定义元数据信息)
 *
 * @author yangylsky
 */
public class FileMetadata extends ObjectMetadata {
	public FileMetadata() {
		super();
	}

	public FileMetadata(ObjectMetadata objectMetadata) {
		this();

		setUserMetadata(objectMetadata.getUserMetadata());
		ReflectionUtils.setFieldValue(this, "metadata", ReflectionUtils.getFieldValue(objectMetadata, "metadata"));
	}

	@Override
	public void setContentLength(long contentLength) {
		if(contentLength > (2097152L * 10)) {
			throw new IllegalArgumentException("内容长度不能超过2M大小。");
		}

		super.setContentLength(contentLength);
	}
}
